home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / dec / qdss / libtl / tlsg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-27  |  16.0 KB  |  511 lines

  1. /***********************************************************
  2. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24.  
  25.  
  26. #include <vaxuba/qevent.h>
  27.  
  28. /*
  29.  * VAXstar device map
  30.  */
  31.  
  32.     struct sgmap {            /* map of register blocks in VAXstar */
  33.  
  34.         char *adder;
  35.         char *fcc;
  36.         char *vdac;
  37.         char *cur;
  38.         char *vrback;
  39.         char *fiforam;
  40.         char *red;
  41.         char *blue;
  42.         char *green;
  43.     };
  44.  
  45.  
  46. /*
  47.  * constants used in font operations
  48.  */
  49.  
  50. #define CHARS        95            /* # of chars in the font */
  51. #define CHAR_HEIGHT    15            /* char height in pixels */
  52. #define CHAR_WIDTH    8            /* char width in pixels*/
  53. #define FONT_WIDTH    (CHAR_WIDTH * CHARS)    /* font width in pixels */
  54. #define FONT_HEIGHT    32
  55. #define FONT_X        0            /* font's off screen adrs */
  56. #define FONT_Y        (2048 - CHAR_HEIGHT)
  57. #define ROWS        CHAR_HEIGHT
  58.  
  59. /*
  60.  * constants used for cursor
  61.  */
  62.  
  63. #define    MAX_CUR_X    1024        /* max cursor x position */
  64. #define    MAX_CUR_Y    864        /* max cursor y position */
  65. #define ACC_OFF     0x01        /* acceleration is inactive */
  66. #define    CURS_ENB    0x0001        /* cursor on */
  67.  
  68. /*
  69.  * VAXstar interrupt controller register bits
  70.  *
  71.  */
  72.  
  73. #define SINT_VS        0x0004
  74. #define SINT_VF        0x0008
  75.  
  76. /*
  77.  * Cursor Command Register bits
  78.  *
  79.  */
  80.  
  81. #define    ENPA    0000001
  82. #define    FOPA    0000002
  83. #define    ENPB    0000004
  84. #define    FOPB    0000010
  85. #define    XHAIR     0000020
  86. #define    XHCLP    0000040
  87. #define    XHCL1    0000100
  88. #define    XHWID    0000200
  89. #define    ENRG1    0000400
  90. #define    FORG1    0001000
  91. #define    ENRG2    0002000
  92. #define    FORG2    0004000
  93. #define    LODSA    0010000
  94. #define    VBHI    0020000
  95. #define    HSHI    0040000
  96. #define    TEST    0100000
  97.  
  98. /*
  99.  * Line Prameter Register bits
  100.  *
  101.  */
  102.  
  103. #define    SER_KBD      000000
  104. #define    SER_POINTER  000001
  105. #define    SER_COMLINE  000002
  106. #define    SER_PRINTER  000003
  107. #define    SER_CHARW    000030
  108. #define    SER_STOP     000040
  109. #define    SER_PARENB   000100
  110. #define    SER_ODDPAR   000200
  111. #define    SER_SPEED    006000
  112. #define    SER_RXENAB   010000
  113.  
  114. /*
  115.  * FCC register and bit definitions
  116.  */
  117.  
  118. #define    IIDLE        0x0001    /* status of "Pixel transfer idle" interrupt */
  119. #define ENIDLE        0x0002  /* enable "Pixel transfer idle" interrupt */
  120. #define    ENTHRSH        0x0040  /* enable FIFO threshold interrupt */
  121. #define    ITHRESH        0x0080    /* status of "FIFO pass threshold" interrupt */
  122.  
  123. /*
  124.  * Color board general CSR bit definitions
  125.  */
  126.  
  127. #define IDLE        0x8000      /* FIFO has data or not */
  128. #define FLUSH        0x4000      /* FIFO complete current operation */
  129. #define    ADDREQ        0x2000      /* ADDER requesting I/O */
  130. #define    PTB_DECOM_ENB    0x1F00      /* host-to-bitmap (use decompression) */
  131. #define PTB_UNPACK_ENB    0x0700      /* host-to-bitmap (unpack bytes) */
  132. #define PTB_ENB        0x0600      /* host-to-bitmap xfer */
  133. #define    BTP_COM_ENB    0x1D00      /* bitmap-to-host (use compression) */
  134. #define BTP_PACK_ENB    0x0500      /* bitmap-to-host (pack bytes) */
  135. #define BTP_ENB        0x0400      /* bitmap-to-host xfer */
  136. /*#define DL_ENB        0x0200      /* display list to ADDER */
  137. /*#define HALT        0x0000      /* halt */
  138. #define    DIAG        0x0080        /* diagnostic mode */
  139. #define    CTESTH        0x0040        /* TEST bit from the cursor chip */
  140. #define    INTMPH        0x0020        /* status bit */
  141. #define    FADR16        0x0002        /* fifo address bit 16 */
  142. #define    FADR15        0x0001        /* fifo address bit 15 */
  143.  
  144.  
  145. /* Software pointer into the VAXstar FIFO */
  146.  
  147. extern u_short * sg_next_fifo;
  148.  
  149. /* VAXstar memcsr bit definitions */
  150.  
  151. #define    UNBLANK            0x0020
  152. #define SYNC_ON            0x0008
  153.  
  154.     struct fcc {
  155.  
  156.         unsigned short cbcsr;    /* color board general CSR */
  157.         unsigned short icsr;    /* interrupt control and status reg. */
  158.         unsigned short fcsr;    /* fifo control and status register */
  159.         unsigned short fwused;    /* fifo words used */
  160.         unsigned short thresh;    /* threshold for comparing with fwused*/
  161.         unsigned short zoo;        /* not used */
  162.         unsigned short put;        /* put pointer for fifo control */
  163.         unsigned short get;        /* get pointer for fifo control */
  164.         unsigned short diag;    /* data for diagnostics modes */
  165.         unsigned short cmpa;
  166.         unsigned short cmpb;
  167.         unsigned short cmpc;    /* pla address bits */
  168.         unsigned short pad[116];
  169.     };
  170.  
  171.  
  172. /* cursor registers */
  173.  
  174.     struct    color_cursor {
  175.         u_short cmdr;        /* command register */
  176.         u_short xpos;        /* x position Register */
  177.         u_short ypos;        /* y position register */
  178.         u_short xmin1;        /* xmin1 active region register */
  179.         u_short xmax1;        /* xmax1 active region register */
  180.         u_short ymin1;        /* ymin1 active region register */
  181.         u_short ymax1;        /* ymax1 active region register */
  182.         u_short pad[4];
  183.         u_short xmin2;        /* xmin2 active region register */
  184.         u_short xmax2;        /* xmax2 active region register */
  185.         u_short ymin2;        /* ymin2 active region register */
  186.         u_short ymax2;        /* ymax2 active region register */
  187.         u_short cmem;        /* cursor memory register */
  188.     };
  189.  
  190. /*
  191.  * macros to transform device coordinates to hardware cursor coordinates
  192.  */
  193.  
  194.  
  195. /*********************************************************************
  196.  *
  197.  *    EVENT QUEUE DEFINITIONS
  198.  *
  199.  *********************************************************************
  200.  * most of the event queue definitions are found in "qevent.h".  But a
  201.  * few things not found there are here.
  202.  */     
  203.  
  204. /* The event queue header */
  205.     
  206. struct sginput {
  207.  
  208.         struct _vs_eventqueue header;  /* event queue ring handling */
  209.  
  210. /* for VS100 and QVSS compatability reasons, additions to this
  211.  * structure must be made below this point.
  212.  */
  213.  
  214.         struct _vs_cursor curs_pos;    /* current mouse position */
  215.         struct _vs_box curs_box;    /* cursor reporting box */
  216.  
  217.     };
  218.     
  219. /* vse_key field.  definitions for mouse buttons */
  220.  
  221. #define VSE_LEFT_BUTTON        0
  222. #define VSE_MIDDLE_BUTTON    1
  223. #define VSE_RIGHT_BUTTON    2
  224.  
  225. /* vse_key field.  definitions for mouse buttons */
  226.  
  227. #define VSE_T_LEFT_BUTTON    0
  228. #define VSE_T_FRONT_BUTTON    1
  229. #define VSE_T_RIGHT_BUTTON    2
  230. #define VSE_T_BACK_BUTTON    4
  231.  
  232. #define VSE_T_BARREL_BUTTON    VSE_T_LEFT_BUTTON
  233. #define VSE_T_TIP_BUTTON    VSE_T_FRONT_BUTTON
  234.  
  235. /*
  236.  * These are the macros to be used for loading and extracting from the event
  237.  * queue.  It is presumed that the macro user will only use the access macros
  238.  * if the event queue is non-empty ( ISEMPTY(eq) == FALSE ), and that the
  239.  * driver will only load the event queue after checking that it is not full
  240.  * ( ISFULL(eq) == FALSE ).  ("eq" is a pointer to the event queue header.)
  241.  *
  242.  *   Before an event access session for a particular event, the macro users
  243.  * must use the xxxBEGIN macro, and the xxxEND macro after an event is through
  244.  * with.  As seen below, the xxxBEGIN and xxxEND macros maintain the event
  245.  * queue access mechanism.
  246.  *
  247.  * First, the macros to be used by the event queue reader 
  248.  */
  249.  
  250. #define ISEMPTY(eq)      ((eq)->header.head == (eq)->header.tail)
  251. #define GETBEGIN(eq)      (&(eq)->header.events[(eq)->header.head]) 
  252.  
  253. #define GET_X(event)      ((event)->vse_x)           /* get x position */
  254. #define GET_Y(event)      ((event)->vse_y)           /* get y position */
  255. #define GET_TIME(event)      ((event)->vse_time)          /* get time */
  256. #define GET_TYPE(event)      ((event)->vse_type)         /* get entry type */
  257. #define GET_KEY(event)      ((event)->vse_key)           /* get keycode */
  258. #define GET_DIR(event)      ((event)->vse_direction)     /* get direction */
  259. #define GET_DEVICE(event) ((event)->vse_device)        /* get device */
  260.  
  261. #define GETEND(eq)        (++(eq)->header.head >= (eq)->header.size ? \
  262.                (eq)->header.head = 0 : 0 )
  263.  
  264. /*
  265.  * macros to be used by the event queue loader
  266.  */
  267.  
  268. /* ISFULL yields TRUE if queue is full */
  269.  
  270. #define ISFULL(eq)    ((eq)->header.tail+1 == (eq)->header.head ||   \
  271.              ((eq)->header.tail+1 == (eq)->header.size &&  \
  272.               (eq)->header.head == 0))
  273.  
  274. /* get address of the billet for NEXT event */
  275.  
  276. #define PUTBEGIN(eq)    (&(eq)->header.events[(eq)->header.tail])
  277.  
  278. #define PUT_X(event, value)      ((event)->vse_x = value)    /* put X pos */
  279. #define PUT_Y(event, value)       ((event)->vse_y = value)    /* put Y pos */
  280. #define PUT_TIME(event, value)    ((event)->vse_time = value)   /* put time */
  281. #define PUT_TYPE(event, value)    ((event)->vse_type = value) /* put type */
  282. #define PUT_KEY(event, value)    ((event)->vse_key = value) /* put input key */
  283. #define PUT_DIR(event, value)    ((event)->vse_direction = value) /* put dir */
  284. #define PUT_DEVICE(event, value) ((event)->vse_device = value)   /* put dev */
  285.  
  286. #define PUTEND(eq)     (++(eq)->header.tail >= (eq)->header.size ?  \
  287.             (eq)->header.tail = 0 : 0) 
  288.  
  289. /******************************************************************
  290.  *
  291.  *    DMA I/O DEFINITIONS
  292.  *
  293.  ******************************************************************/
  294.  
  295. /*
  296.  * The DMA request queue is implemented as a ring buffer of "DMAreq"
  297.  * structures.  The queue is accessed using ring indices located in the
  298.  * "DMAreq_header" structure.  Access is implemented using access macros
  299.  * similar to the event queue access macros above.
  300.  */
  301.  
  302.     struct FIFOreq {
  303.  
  304.         short FIFOtype;        /* FIFO type code */
  305.         char  *bufp;        /* virtual adrs of buffer */
  306.         int   length;            /* transfer buffer length */
  307.     };
  308.  
  309. /* DMA type command codes */
  310.  
  311. #define DISPLIST    1    /* display list DMA */
  312. #define PTOB        2    /* 1 plane Qbus to bitmap DMA */
  313. #define BTOP        3    /* 1 plane bitmap to Qbus DMA */
  314.  
  315. /* DMA done notification code */
  316.  
  317. #define FIFO_EMPTY    0x01    /* DONE when FIFO becomes empty */
  318. #define COUNT_ZERO    0x02    /* DONE when count becomes zero */
  319. #define WORD_PACK    0x04    /* program the gate array for word packing */
  320. #define BYTE_PACK    0x08    /* program gate array for byte packing */
  321. #define REQUEST_DONE    0x100    /* clear when driver has processed request */
  322. #define HARD_ERROR    0x200   /* DMA hardware error occurred */
  323.  
  324. /* DMA request queue is a ring buffer of request structures */
  325.  
  326.     struct FIFOreq_header {
  327.  
  328.         short status;        /* master FIFO status word */
  329.         int shared_size;        /* size of shared memory in bytes */
  330.         struct FIFOreq *FIFOreq;  /* start address of request queue */
  331.         int used;            /* # of queue entries currently used */
  332.         int size;            /* # of "FIFOreq"'s in the request queue */
  333.         int oldest;            /* index to oldest queue'd request */
  334.         int newest;            /* index to newest queue'd request */
  335.         short  change_section;
  336.         short  sg_int_flag;
  337.         u_short sg_next_fifo;
  338.     };
  339.  
  340. /* bit definitions for DMAstatus word in DMAreq_header */
  341.  
  342. #define    DMA_ACTIVE    0x0004        /* DMA in progress */
  343. #define DMA_ERROR    0x0080        /* DMA hardware error */
  344. #define DMA_IGNORE    0x0002        /* flag to ignore this interrupt */
  345.  
  346. /*
  347.  * macros for DMA request queue fiddling
  348.  */
  349.  
  350.     /* DMA status set/check macros */
  351.  
  352. #define DMA_SETACTIVE(header)   ((header)->status |= DMA_ACTIVE)
  353. #define DMA_CLRACTIVE(header)    ((header)->status &= ~DMA_ACTIVE)
  354. #define DMA_ISACTIVE(header)    ((header)->status & DMA_ACTIVE)
  355.  
  356. #define DMA_SETERROR(header)    ((header)->status |= DMA_ERROR)
  357. #define DMA_CLRERROR(header)    ((header)->status &= ~DMA_ERROR)
  358. #define DMA_ISERROR(header)     ((header)->status & DMA_ERROR)
  359.  
  360. #define DMA_SETIGNORE(header)    ((header)->status |= DMA_IGNORE)
  361. #define DMA_CLRIGNORE(header)   ((header)->status &= ~DMA_IGNORE)
  362. #define DMA_ISIGNORE(header)    ((header)->status & DMA_IGNORE)
  363.  
  364. /* yields TRUE if queue is empty (ISEMPTY) or full (ISFULL) */
  365.  
  366. #define DMA_ISEMPTY(header)    ((header)->used == 0)
  367. #define DMA_ISFULL(header)    ((header)->used >= (header)->size)
  368.  
  369. /* returns address of the billet for next (PUT)
  370.  * or oldest (GET) request
  371.  */
  372.  
  373. #define FIFO_PUTBEGIN(header)    (&(header)->FIFOreq[(header)->newest])
  374. #define FIFO_GETBEGIN(header)      (&(header)->FIFOreq[(header)->oldest])
  375.  
  376. #define DMA_PUTBEGIN(header)    (&(header)->DMAreq[(header)->newest])
  377. #define DMA_GETBEGIN(header)      (&(header)->DMAreq[(header)->oldest])
  378.  
  379. /* does queue access pointer maintenance */
  380.  
  381. #define DMA_GETEND(header)      (++(header)->oldest >= (header)->size    \
  382.                   ? (header)->oldest = 0 : 0);         \
  383.                 --(header)->used;
  384.  
  385. #define DMA_PUTEND(header)         (++(header)->newest >= (header)->size    \
  386.                   ? (header)->newest = 0 : 0);         \
  387.                 ++(header)->used;
  388.  
  389. /******************************************************************
  390.  *
  391.  *    COLOR MAP WRITE BUFFER DEFINITIONS
  392.  *
  393.  ******************************************************************/
  394.  
  395. #define LOAD_COLOR_MAP    0x0001
  396.  
  397. /******************************************************************
  398.  *
  399.  *    SCROLL ASSIST DEFINITIONS
  400.  *
  401.  ******************************************************************/
  402.  
  403. #define LOAD_REGS    0x0001
  404. #define LOAD_INDEX    0x0002
  405.  
  406. /******************************************************************
  407.  *
  408.  *    MOUSE/TABLET/KBD PROGRAMMING DEFINITIONS
  409.  *
  410.  ******************************************************************/
  411.  
  412. /*
  413.  * LK201 programmming definitions
  414.  */
  415.  
  416. #define LK_UPDOWN     0x86        /* bits for setting lk201 modes */
  417. #define LK_AUTODOWN     0x82
  418. #define LK_DOWN     0x80
  419. #define LK_DEFAULTS     0xD3        /* reset (some) default settings */
  420. #define LK_AR_ENABLE     0xE3        /* global auto repeat enable */
  421. #define LK_CL_ENABLE     0x1B        /* keyclick enable */
  422. #define LK_KBD_ENABLE     0x8B        /* keyboard enable */
  423. #define LK_BELL_ENABLE     0x23        /* the bell */
  424. #define LK_RING_BELL     0xA7        /* ring keyboard bell */
  425.  
  426. #define LK_LED_ENABLE     0x13        /* light led */
  427. #define LK_LED_DISABLE     0x11        /* turn off led */
  428. #define LED_1         0x81        /* led bits */
  429. #define LED_2         0x82
  430. #define LED_3         0x84
  431. #define LED_4         0x88
  432. #define LED_ALL     0x8F
  433. #define LK_LED_HOLD    LED_4
  434. #define LK_LED_LOCK    LED_3
  435. #define LK_LED_COMPOSE    LED_2
  436. #define LK_LED_WAIT     LED_1
  437.  
  438. #define LK_KDOWN_ERROR    0x3D        /* key down on powerup error */
  439. #define LK_POWER_ERROR     0x3E        /* keyboard failure on powerup test */
  440. #define LK_OUTPUT_ERROR    0xB5        /* keystrokes lost during inhibit */
  441. #define LK_INPUT_ERROR     0xB6        /* garbage command to keyboard */
  442. #define LK_LOWEST    0x56        /* lowest significant keycode */
  443. #define LK_DIV6_START    0xAD        /* start of div 6 */
  444. #define LK_DIV5_END    0xB2        /* end of div 5 */
  445.  
  446. #define LAST_PARAM    0x80        /* "no more params" bit */
  447.  
  448. /*
  449.  * "special" LK-201 keys
  450.  */
  451.  
  452. #define SHIFT        174
  453. #define LOCK        176
  454. #define REPEAT        180
  455. #define CNTRL        175
  456. #define ALLUP        179
  457. #define HOLD         86
  458.  
  459. /*
  460.  * cursor programming structure
  461.  */
  462.  
  463. /*
  464.  * mouse definitions
  465.  */
  466.  
  467. #define INCREMENTAL    'R'        /* stream mode reports (55 hz) */
  468. #define PROMPT_MODE    'D'        /* report when prompted */
  469. #define REQUEST_POS    'P'        /* request position report */
  470. #define SELF_TEST    'T'        /* request self test */
  471.  
  472. #define MOUSE_ID    0x2        /* mouse ID in lo 4 bits */
  473.  
  474. #define START_FRAME    0x80        /* start of report frame bit */
  475. #define X_SIGN        0x10        /* position sign bits */
  476. #define Y_SIGN        0x08
  477.  
  478. #define RIGHT_BUTTON    0x01        /* mouse buttons */
  479. #define MIDDLE_BUTTON    0x02
  480. #define LEFT_BUTTON    0x04
  481.  
  482.  
  483. /*
  484.  * tablet command/interface definitions
  485.  */
  486.  
  487. #define T_STREAM    'R'        /* continuous stream report mode */
  488. #define T_POINT         'D'        /* enter report-on-request mode */
  489. #define T_REQUEST    'P'        /* request position report */
  490.  
  491. #define T_BAUD        'B'        /* increase baud to 9600 from 4800 */
  492. #define T_RATE_55    'K'        /* report rate: 55/sec */
  493. #define T_RATE_72    'L'        /* report rate: 72/sec */
  494. #define T_RATE_120    'M'        /* report rate: 120/sec (9600 only) */
  495.  
  496. #define T_TEST        SELF_TEST    /* do self test */
  497.  
  498. #define TABLET_ID    0x4        /* tablet ID in lo 4 bits */
  499.  
  500. #define T_START_FRAME    0x80        /* start of report frame bit */
  501. #define T_PROXIMITY    0x01        /* state pointer in proximity */
  502.  
  503. #define T_LEFT_BUTTON    0x02        /* puck buttons */
  504. #define T_FRONT_BUTTON    0x04
  505. #define T_RIGHT_BUTTON    0x08
  506. #define T_BACK_BUTTON    0x10
  507.  
  508. #define T_BARREL_BUTTON T_LEFT_BUTTON        /* stylus buttons */
  509. #define T_TIP_BUTTON    T_FRONT_BUTTON
  510.  
  511.